/**********************************************************************************************************************
 *
 * Project:    mGameEngine
 * File:       revolutejoint.h
 * Author:     karooolek
 * Created on: Nov 19, 2009
 *
 **********************************************************************************************************************/

#ifndef REVOLUTEJOINT_H_
#define REVOLUTEJOINT_H_

#include "joint.h"

namespace mGameEngine
{
namespace Physics
{

/**
 * Revolute joint.
 * Revolute joint joins two points on two different actors.
 * Only rotation around specified axis is allowed.
 * Maximal twist is maximal rotation around joint anchor axis.
 */
class RevoluteJoint : public Joint
{
protected:
    /**
     * Maximal joint twist.
     */
    float _maxTwist;

public:
    /**
     * Create revolute joint with specified anchor positions and axles.
     * @param point1 first anchor position.
     * @param point2 second anchor position
     * @param axis1 first anchor axis.
     * @param axis2 second anchor axis.
     * @param maxTwist maximal twist.
     */
    RevoluteJoint(const Vector3 &point1 = Vector3(),
                  const Vector3 &point2 = Vector3(),
                  const Vector3 &axis1 = Vector3(1.0f, 0.0f, 0.0f),
                  const Vector3 &axis2 = Vector3(-1.0f, 0.0f, 0.0f),
                  float maxTwist = M_PI);

    /**
     * Destroy revolute joint.
     */
    virtual ~RevoluteJoint();

    /**
     * Get joint maximal twist.
     * @return joint maximal twist in radians.
     */
    float getMaximalTwist() const
    {
        return _maxTwist;
    }

    /**
     * Set joint maximal twist.
     * @param maxTwist maximal twist in radians.
     */
    virtual void setMaximalTwist(float maxTwist);

    /**
     * Create PhysX revolute joint between two PhysX actors.
     * @param actor1 first PhysX actor.
     * @param actor2 second PhysX actor.
     */
    virtual void create(NxActor *actor1, NxActor *actor2) const;
};

}
}

#endif // REVOLUTEJOINT_H_
